<?php
class Movie_model extends CI_Model {
	function getAll() {
		$query = $this->db->get ( 'movie' );
		return $query->result ( 'Movie' );
	}
	function get($id) {
		$query = $this->db->get_where ( 'movie', array (
				'id' => $id 
		) );
		
		return $query->row ( 0, 'Movie' );
	}
	function delete($id) {
		return $this->db->delete ( 'movie', array (
				'id' => $id 
		) );
	}
	function insert($id, $title) {
		return $this->db->insert ( 'movie', array (
				'id' => $id,
				'title' => $title 
		) );
	}
	function update($movie) {
		$this->db->where ( 'id', $movie->id );
		return $this->db->update ( 'movie', array (
				'id' => $movie->id,
				'title' => $movie->title 
		) );
	}
	
	function show_movies() {
		return $this->db->query("select title from movie");
	}
}
?>